<?php
/**
 * Created by IntelliJ IDEA.
 * User: jimmyhsu
 * Date: 2017/4/15
 * Time: 00:45
 */
include ('checkLogin.php');
$course_id = $_GET['course_id'];
$stu_id = $_GET['stu_id'];
$type = $_GET['type'];
if ($type == 'add') {
    $sql = "update takes set position='assistant' where course_id='$course_id' and id in (select id from userinfo where studentid='$stu_id')";
    if (mysqli_query($cn, $sql)) {
        echo 'success';
    } else {
        echo 'error:db';
    }
} else if ($type == 'remove') {
    $sql = "update takes set position='student' where course_id='$course_id' and id in (select id from userinfo where studentid='$stu_id')";
    if (mysqli_query($cn, $sql)) {
        echo 'success';
    } else {
        echo 'error:db';
    }
}